<?php
/**
 * @title 104. 二叉树的最大深度 - 递归
 * @author start2004
 */

class Solution {

    /**
     * @param TreeNode $root
     * @return Integer
     */
    function maxDepth($root) {
        /**
         * @since 2020-07-28 极端情况
         */
        if($root === null){
            return 0;
        } else {}

        /**
         * @return
         */
        return max(self::maxDepth($root->left), self::maxDepth($root->right))+1;
    }
}





/**
 * @url http://127.0.0.1/leetcode/202007/2020.07.28_5.php
 */
$datas = [
    [3,9,20,null,null,15,7],
];

include_once dirname(__DIR__) . DIRECTORY_SEPARATOR ."xhprof.php";
$xhprof = new Xhprof();
foreach ($datas as $data){
    var_dump($data);

    $obj = new Solution();
    $result = $obj->maxDepth($xhprof->tree($data));
    var_dump($result);
    echo str_repeat("<br>", 3);
}
$xhprof->end();
